<template>
  <div class="home-container">
    <div class="banner-section">
      <el-carousel height="200px">
        <el-carousel-item v-for="item in banners" :key="item.id">
          <img :src="item.image" :alt="item.title" class="banner-image" />
        </el-carousel-item>
      </el-carousel>
    </div>
    
    <div class="section">
      <div class="section-header">
        <h3>推荐歌单</h3>
        <el-button text type="primary">更多</el-button>
      </div>
      <div class="playlist-grid">
        <div v-for="playlist in recommendedPlaylists" :key="playlist.id" class="playlist-card">
          <img :src="playlist.cover" :alt="playlist.name" class="playlist-cover" />
          <div class="playlist-info">
            <div class="playlist-name">{{ playlist.name }}</div>
            <div class="playlist-count">{{ playlist.count }}首</div>
          </div>
        </div>
      </div>
    </div>
    
    <div class="section">
      <div class="section-header">
        <h3>最新音乐</h3>
        <el-button text type="primary">更多</el-button>
      </div>
      <div class="song-list">
        <div v-for="song in newSongs" :key="song.id" class="song-item">
          <img :src="song.cover" :alt="song.name" class="song-cover" />
          <div class="song-info">
            <div class="song-name">{{ song.name }}</div>
            <div class="song-artist">{{ song.artist }}</div>
          </div>
          <div class="song-duration">{{ song.duration }}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'

const banners = ref([
  { id: 1, title: '热门推荐', image: 'https://via.placeholder.com/800x200/409eff/fff?text=热门推荐' },
  { id: 2, title: '新歌首发', image: 'https://via.placeholder.com/800x200/67c23a/fff?text=新歌首发' },
  { id: 3, title: '独家音乐', image: 'https://via.placeholder.com/800x200/e6a23c/fff?text=独家音乐' }
])

const recommendedPlaylists = ref([
  { id: 1, name: '流行热歌', cover: 'https://via.placeholder.com/150', count: 50 },
  { id: 2, name: '经典老歌', cover: 'https://via.placeholder.com/150', count: 30 },
  { id: 3, name: '轻音乐', cover: 'https://via.placeholder.com/150', count: 25 },
  { id: 4, name: '摇滚精选', cover: 'https://via.placeholder.com/150', count: 40 }
])

const newSongs = ref([
  { id: 1, name: '夜曲', artist: '周杰伦', cover: 'https://via.placeholder.com/50', duration: '3:45' },
  { id: 2, name: '晴天', artist: '周杰伦', cover: 'https://via.placeholder.com/50', duration: '4:30' },
  { id: 3, name: '七里香', artist: '周杰伦', cover: 'https://via.placeholder.com/50', duration: '4:15' },
  { id: 4, name: '稻香', artist: '周杰伦', cover: 'https://via.placeholder.com/50', duration: '3:55' }
])
</script>

<style scoped>
.home-container {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.banner-section {
  margin-bottom: 30px;
}

.banner-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}

.section {
  margin-bottom: 30px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.section-header h3 {
  margin: 0;
  color: #303133;
}

.playlist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 20px;
}

.playlist-card {
  cursor: pointer;
  transition: transform 0.2s;
}

.playlist-card:hover {
  transform: translateY(-2px);
}

.playlist-cover {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  margin-bottom: 8px;
}

.playlist-name {
  font-size: 14px;
  font-weight: bold;
  color: #303133;
  margin-bottom: 4px;
}

.playlist-count {
  font-size: 12px;
  color: #909399;
}

.song-list {
  background: white;
  border-radius: 8px;
  overflow: hidden;
}

.song-item {
  display: flex;
  align-items: center;
  padding: 10px 15px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background-color 0.2s;
}

.song-item:hover {
  background-color: #f5f7fa;
}

.song-item:last-child {
  border-bottom: none;
}

.song-cover {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  margin-right: 15px;
}

.song-info {
  flex: 1;
}

.song-name {
  font-size: 14px;
  color: #303133;
  margin-bottom: 2px;
}

.song-artist {
  font-size: 12px;
  color: #909399;
}

.song-duration {
  font-size: 12px;
  color: #909399;
}
</style>
